--获得排行榜情况
local skynet = require "skynet"
local filelog = require "filelog"
local msghelper = require "ranklistsvrhelper"
local ranklistredismng = require"ranklistredismng"
local base = require "base"
local playerdatadao = require "playerdatadao"
local redisdao = require "dao.redisdao"
require "enum"


local RankListsvrRequest = {}

function RankListsvrRequest.process(session, source, event, ...)
	local f = RankListsvrRequest[event] 
	if f == nil then
		return
	end
	f(...)
end


--获得稳定排行榜情况（金币币排行榜，...）
function RankListsvrRequest.get_ranklist_info(request)
	local server = msghelper:get_server()	
	
	local responsemsg = {
		errcode = EErrCode.ERR_SUCCESS,
	}

	local rank_key  = request.rank_key
	--rank_key = 5
	responsemsg.rank_key = rank_key
	responsemsg.rankinfo = ranklistredismng.get_ranklist(rank_key, request.rank_begin, request.rank_num, request.adress_gps or 0)
	if responsemsg.rankinfo == nil then
		responsemsg.errcode = EErrCode.ERR_INVALID_REQUEST
		responsemsg.errcodedes = "无效请求！"
	end
	
	base.skynet_retpack(responsemsg)
end

function RankListsvrRequest.search_update_time( rid, key )
	local svr_id = msghelper:get_conf().ranklistdb.svr_id
	local result, time = redisdao.query_data(svr_id, "GET", key)
	base.skynet_retpack(state, time)
end

return RankListsvrRequest